<style>
</style>
<template>
    <span>
    <Drawer title="积分记录" :closable="false" placement="right" v-model="staffDrawer" width="50%">
        <Row style="padding-top: 5px">
            <Table :loading="loading" border :columns="userColumns" :data="userData" ref="userTable"></Table>
        </Row>
        <Row type="flex" justify="end" class="page">
            <Page :current="searchForm.pageNumber" :total="total" :page-size="searchForm.pageSize" @on-change="changePage" @on-page-size-change="changePageSize" :page-size-opts="[10,20,50]" size="small" show-total show-elevator show-sizer></Page>
        </Row>
    </Drawer>
    </span>
</template>
<script>
    import {scoreList} from "@/api/bus";

    export default {
        name: "recordDrawer",
        props: {
            id: ""
        },
        data() {
            return {
                modalVisible: false,
                submitLoading:false,
                staffDrawer: false,
                modalTitle: '积分记录',
                loading: true,
                addUserForm: {
                    hrScore: "",
                    userabilityId: ""
                },
                searchForm: {
                    pageNumber: 1, // 当前页数
                    pageSize: 10, // 页面大小
                    sort: "createTime", // 默认排序字段
                    order: "desc", // 默认排序方式
                    userId: ""
                },
                permData: [],
                userColumns: [
                    {
                        type: "index",
                        width: 60,
                        align: "center"
                    },
                    {
                        title: "积分",
                        key: "integral"
                    },
                    {
                        title: "积分描述",
                        key: "recordBody",
                        sortable: true
                    },
                    {
                        title: "积分获取时间",
                        key: "createTime",
                        sortable: true
                    }
                ],
                userData: [],
                total: 0
            }
        },
        methods: {
            //加载数据
            showDrawer(params){
                this.staffDrawer = true;
                if (params.id) {
                    this.searchForm.userId = params.id;
                    this.getData();
                }
            },
            getData() {
                this.loading = true;
                scoreList(this.searchForm).then(res => {
                    this.loading = false;
                    if (res.status === true) {
                        this.userData = res.data.rows;
                        this.total = res.data.total;
                    }
                });
            },
            markScore(uId) {
                this.modalVisible = true;
                this.addUserForm.userabilityId = uId;
            },
            changePageSize(v) {
                this.searchForm.pageSize = v;
                this.getData();
            },
            changePage(v) {
                this.searchForm.pageNumber = v;
                this.getData();
                this.clearSelectAll();
            },
            clearSelectAll() {
                this.$refs.table.selectAll(false);
            },
            cancelSubmit() {
                this.modalVisible = false;
            },
        },
        mounted() {

        }
    }
</script>